package ctrLayer;

import modelLayer.*;

import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class VareCtrTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class VareCtrTest
{
    /**
     * Default constructor for test class VareCtrTest
     */
    public VareCtrTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
        VareCtr vareCtr = new VareCtr();
        VareContainer vc = VareContainer.getInstance();
        vc.sletVare("hammer");
    }

    @Test
    public void opretMarkedsVare()
    {
        VareCtr vareCtr = new VareCtr();
        
        boolean fejl = false;
        try
        {
            vareCtr.tilfoejMarkedsVare(null, "hammer", "stor hammer", 37, 100, 10, 9);
        }
        catch (Exception e)
        {
            fejl = true;
        }
        assertEquals(false, fejl);
    }

    @Test
    public void opretVareDuplikation()
    {
        VareCtr vareCtr = new VareCtr();
        
        boolean fejl = false;
        try
        {
            vareCtr.tilfoejMarkedsVare(null, "hammer", "stor hammer", 37, 100, 10, 9);
            vareCtr.tilfoejMarkedsVare(null, "hammer", "stor hammer", 37, 100, 10, 9);
        }
        catch (Exception e)
        {
            fejl = true;
        }
        assertEquals(true, fejl);
    }

    @Test
    public void opretVareMinLagerStoerreEndMaxLager()
    {
        VareCtr vareCtr = new VareCtr();
        
        boolean fejl = false;
        try
        {
            vareCtr.tilfoejMarkedsVare(null, "hammer", "stor hammer", 37, 50, 100, 9);
        }
        catch (Exception e)
        {
            fejl = true;
        }
        assertEquals(true, fejl);
    }
}



